package com.example.lean;

import androidx.appcompat.app.AppCompatActivity;

import android.graphics.Color;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

public class MainActivity extends AppCompatActivity {

    //声明代表UI组件的变量
    EditText fname,sname, phone;
    TextView txv;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        // 隐藏标题栏
        // activity默认继承了AppCompatActivity时
        getSupportActionBar().hide();
        //activity默认继承了Activity时 requestWindowFeature(Window.FEATURE_NO_TITLE);

        setContentView(R.layout.activity_main);

        //初始化变量
        fname = findViewById(R.id.firstName);
        sname = findViewById(R.id.surName);
        phone = findViewById(R.id.phone);
        txv = (TextView) findViewById(R.id.txv);

        //紫色
        fname.setTextColor(Color.rgb(255, 0, 255));
        //红色50%透明度
        sname.setTextColor(Color.argb(127, 255, 0, 0));
        //红色
        txv.setTextColor(Color.RED);
    }

    public void myClick(View view) {
        txv.setText(fname.getText().toString() + sname.getText().toString() + "的电话是" + phone.getText());
        Toast.makeText(this, "这是xml方式指定的Button响应", Toast.LENGTH_LONG).show();
    }
}